﻿package  
{
	import flash.utils.Dictionary;
	public class CollisionMap 
	{	
		private var m_traversableMap : Dictionary;
		private var m_columnSize : int = 0;
		private var m_rowSize : int = 0;
		
		public function CollisionMap() 
		{
			m_traversableMap = new Dictionary();
		}		
		
		public function setTraversable( a_column : int, a_row : int, a_traversable : Boolean ) : void
		{
			var key : String = calculateKey( a_column, a_row );
			
			m_columnSize = Math.max( m_columnSize, a_column + 1 );
			m_rowSize = Math.max( m_rowSize, a_row + 1 );
			
			if( a_traversable )
			{
				m_traversableMap[ key ] = true;
			}
			else
			{
				delete m_traversableMap[ key ];
			}
		}
		
		public function isTraversable( a_column : int, a_row : int ) : Boolean
		{
			var key : String = calculateKey( a_column, a_row );
			
			if( m_traversableMap[ key ] == true ) return true;
			
			return false;
		}
		
		private function calculateKey( a_column : int, a_row : int ) : String
		{
			return a_column + "_" + a_row;
		}
		
		public function get columnSize():int { return m_columnSize; }		
		public function get rowSize():int { return m_rowSize; }
	}	
}